const express = require("express");
const router = express.Router();
const expressJoi = require("@escook/express-joi");

const userHandler = require("../router_handler/user"); // 对应处理函数
const userValidate = require("../router_data_validate/user"); // 验证规则

// 路由模块中只关注对应关系，不处理逻辑

/** 注册 */
router.post("/reguser", expressJoi(userValidate.userReg), userHandler.regUser);

/** 登录 */
router.post("/login", expressJoi(userValidate.userReg), userHandler.login);

/** 获取用户信息 */
router.get("/getUserInfo", userHandler.getUserInfo);

/** 更新用户信息 */
router.post(
  "/updateUserInfo",
  expressJoi(userValidate.updateUserInfo),
  userHandler.updateUserInfo
);

/** 重置密码 */
router.post(
  "/resetPwd",
  expressJoi(userValidate.resetPwd),
  userHandler.resetPwd
);

/** 更换头像 */
router.post(
  "/updateUserImg",
  expressJoi(userValidate.updateUserImg),
  userHandler.updateUserImg
);

module.exports = router;
